package com.snopy.stream;

import lombok.extern.slf4j.Slf4j;

import java.io.*;

/**
 * @author snopy
 * @version 1.0.0
 * @classname CopyLineOriented
 * @description
 * @email 77912204@qq.com
 * @date 2022/07/29 15:44
 */
@Slf4j
public class CopyLineOriented {
    public static void main(String[] args) {
        BufferedReader inputStream = null;
        PrintWriter outputStream = null;
        try {
            inputStream = new BufferedReader(new FileReader("Sonata_java8/src/main/resources/xanadu.txt"));
            outputStream = new PrintWriter(new FileWriter("Sonata_java8/src/main/resources/lineoutput.txt"));
            String r;
            while ((r=inputStream.readLine())!=null){
                outputStream.println(r);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            if (inputStream!=null){
                try {
                    inputStream.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            if (outputStream!=null){
                outputStream.close();
            }
        }
    }
}
